import React, { Component } from 'react';
import { getUrlParam } from '../../utils/tools'
import {selectDetailsById} from "../../utils/interface"
import SubCard from './subCard'
import SubCardList from './subCradList'
class SubCardBox extends Component {
    constructor(props) {
        super(props);
        this.state = { 
            count:0
         }
    }
    render() { 
        let  that = this
        function Html(){
            if(that.state.count===1){
                return <SubCardList />
            }else if(that.state.count===2){
                return  <SubCard></SubCard>
            }
        }
        return (<div>{this.state.count? <Html></Html> :''}</div>);
    }
    componentDidMount(){
        this.getCardInfo(getUrlParam('cardId'))
    }
    getCardInfo(id){
        selectDetailsById({memberCardId:id}).then(res=>{
            // alert(JSON.stringify(res.data.result))
            if(res.data.result.subCount>0){
                this.setState({
                    count:1
                })
            }else{
                this.setState({
                    count:2
                })
            }
        })
    }
}
 
export default SubCardBox;